/**
 * @file		functionArray.cpp
 * @description	Demonstrates passing array elements to functions.
 * @course		CSCI 123 Section 00000
 * @assignment 
 * @date		mm/dd/yyyy
 * @author		Brad Rippe (00000000) brippe@fullcoll.edu
 * @version		1.0
 */
#include <iostream>
#include <cctype>
using namespace std;

const int NUMBER_OF_GRADES = 2;

/**
 * Converts the character to uppercase 
 * @pre		element is initialized to a letter
 * @post	element is converted to an uppercase character
 * @param	element the character to convert to an uppercase character
 * @return	the character as an uppercase character
 */
char toUpperArrayElement(char element);

/**
 * @return zero if the application executes successfully
 */
int main() {
	// declares the array
	char grades[NUMBER_OF_GRADES];

	cout << "Please type in five grades (A,B,C,D, or F)\n";
	// Arrays are indexed from 0...size-1
	// This loop initializes all the values in the array
	// by getting the value from the user
	for(int i = 0; i < NUMBER_OF_GRADES; i++) {
		cout << "Grade " << (i+1) << ": ";
		cin >> grades[i];
	}

	// Arrays are indexed from 0...size-1
	// output the values of grades
	cout << "You typed\n";
	for(int i = 0; i < NUMBER_OF_GRADES; i++) {
		// we can use array elements as parameters to functions
		// notice the use of static_cast<char>(toupper())
		// the return value of toupper is used as a parameter
		// to the static_cast function
		cout << "Grade " << (i+1) << " = " 
		     << toUpperArrayElement(grades[i]) << endl;
	}
	return 0;
}

char toUpperArrayElement(char element) {
	return toupper(element); // can you explain what happens here
}

